package com.motong.gongdan.vo.system.device.query;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.util.StringUtils;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Date;
import java.util.List;

@Data
@ApiModel("设备状态请求参数")
@Accessors(chain = true)
public class StatusDashboardQuery {

    @ApiModelProperty("分组id")
    public String groupId;

    @ApiModelProperty("分组id(多个以,号隔开)")
    public String groupIds;

    @ApiModelProperty(value = "idList", hidden = true)
    private List<String> groupIdList = new ArrayList<>();


    @ApiModelProperty(value = "设备id", hidden = true)
    public Long deviceId;

    @ApiModelProperty(value = "开始时间", hidden = true)
    public Date startTime;

    @ApiModelProperty(value = "结束时间", hidden = true)
    public Date endTime;

    @ApiModelProperty(value = "显示离线", hidden = true)
    public Boolean showOffline = true;

    @ApiModelProperty("显示关机")
    public Boolean showClose = false;

    @ApiModelProperty("设备状态(多个以,号隔开)")
    public String deviceStatus;

    @ApiModelProperty("设备状态")
    public List<String> deviceStatusList = new ArrayList<>();

    @ApiModelProperty(value = "页码")
    private Integer page = 1;

    @ApiModelProperty(value = "条数")
    private Integer limit = -1;

    /*逗号分隔格式化为数组*/
    public void setDeviceStatus(String deviceStatus) {
        if (StringUtils.hasLength(deviceStatus)) {
            deviceStatusList.addAll(Arrays.asList(deviceStatus.split(",")));
        }
        this.deviceStatus = deviceStatus;
    }

    /*逗号分隔格式化为数组*/
    public void setGroupIds(String groupIds) {
        if (StringUtils.hasLength(groupIds)) {
            this.groupIdList.addAll(Arrays.asList(groupIds.split(",")));
        }
        this.groupIds = groupIds;
    }
}
